import request from "@/utils/request";

export interface TrademarkData {
  id?: number;
  logoUrl: string;
  tmName: string;
}

type TrademarkPageListData = {
  records: TrademarkData[];
  total: number;
  size: number;
  current: number;
  searchCount: boolean;
  pages: number;
};

export default {
  // DELETE /admin/product/baseTrademark/remove/{id}
  // 删除BaseTrademark
  delete(id: number) {
    return request.delete<any, null>(
      `/admin/product/baseTrademark/remove/${id}`
    );
  },

  // id是存库的时候生成的id
  // 因此添加是没有id的,但是修改是有id

  // POST /admin/product/baseTrademark/save
  // 新增BaseTrademark
  // PUT /admin/product/baseTrademark/update
  // 修改BaseTrademark
  addOrUpdate(trademark: TrademarkData) {
    if (trademark.id) {
      return request.put<any, null>(
        "/admin/product/baseTrademark/update",
        trademark
      );
    } else {
      return request.post<any, null>(
        "/admin/product/baseTrademark/save",
        trademark
      );
    }
  },

  // GET /admin/product/baseTrademark/{page}/{limit}
  // 分页列表
  getPageList(page: number, limit: number) {
    return request.get<any, TrademarkPageListData>(
      `/admin/product/baseTrademark/${page}/${limit}`
    );
  },

  //获取trademark列表信息
  getList() {
    return request.get<any, TrademarkData[]>(
      "/admin/product/baseTrademark/getTrademarkList"
    );
  },
};